package com.useful.core.convert;

import com.useful.core.utils.DateUtil;
import org.mapstruct.Named;

import java.util.Date;

/**
 * <p>
 * 用法：
 * {@link org.mapstruct.Mapper)}
 * 在interface头的 Mapper注解的users方法中引入此类
 * (uses = {TypeConverts.class})
 * <p>
 * {@link org.mapstruct.Mapping}
 * 在方法上写入映射
 * (source = "updateTime", target = "updateTime", qualifiedByName = "stringToDate")
 * 需要多个映射则 使用 {@link org.mapstruct.Mappings}
 *
 * </p>
 * {@code
 * public
 * }
 *
 * @author : wenchao.long
 * @date : Created in 2021/9/22 14:38 周三
 * @description :
 */
@Named("TypeConverts")
public class TypeConverts {

    @Named("stringToDate")
    public Date parse(String str) {
        return DateUtil.parseDateTime(str);
    }

    @Named("dateToString")
    public String formatDateTime(Date date) {
        return DateUtil.formatDateTime(date);
    }
}
